package xm.erzhan.conf.ResourcesConf;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Steelmill {
    private static Steelmill steelmillIns;

    public class SteelmillItem {
        public int lv;
        public int costFood;
        public int costSteel;
        public int costOil;
        public int costSlime;
        public int product;
        public int costSec;

        public SteelmillItem(int lv, int costFood, int costSteel, int costOil, int costSlime, int product, int costSec) {
            this.lv = lv;
            this.costFood = costFood;
            this.costSteel = costSteel;
            this.costOil = costOil;
            this.costSlime = costSlime;
            this.product = product;
            this.costSec = costSec;
        }

    }

    public List<Steelmill.SteelmillItem> steelmillItems = new ArrayList<Steelmill.SteelmillItem>();

    public Steelmill.SteelmillItem getConfByLv(int lv) {

        Steelmill.SteelmillItem steelmillItem = null;

        Iterator<Steelmill.SteelmillItem> iterator = this.steelmillItems.iterator();

        Steelmill.SteelmillItem item;
        while (iterator.hasNext()) {
            item = iterator.next();
            if (item.lv == lv) {
                steelmillItem = item;
                break;
            }
        }

        return steelmillItem;
    }

    public void initSteelmillItems() {

        this.steelmillItems.add(new Steelmill.SteelmillItem(1, 200, 200, 150, 250, 500, 5));
        this.steelmillItems.add(new Steelmill.SteelmillItem(2, 500, 700, 450, 750, 1000, 15));
        this.steelmillItems.add(new Steelmill.SteelmillItem(3, 1300, 1500, 1450, 1550, 4500, 30));
        this.steelmillItems.add(new Steelmill.SteelmillItem(4, 2500, 2700, 1650, 2750, 5000, 100));
        this.steelmillItems.add(new Steelmill.SteelmillItem(5, 3500, 5700, 2600, 7750, 8000, 150));
        this.steelmillItems.add(new Steelmill.SteelmillItem(6, 13500, 15700, 12650, 17750, 13500, 230));
        this.steelmillItems.add(new Steelmill.SteelmillItem(7, 22100, 22200, 21150, 22250, 25000, 280));
        this.steelmillItems.add(new Steelmill.SteelmillItem(8, 40100, 40200, 40150, 40250, 40500, 360));
        this.steelmillItems.add(new Steelmill.SteelmillItem(9, 60100, 60200, 60150, 60250, 60500, 480));
    }

    public static Steelmill shared() {
        if (steelmillIns == null) {
            steelmillIns = new Steelmill();
            steelmillIns.initSteelmillItems();
        }

        return steelmillIns;
    }
}
